package xyz.zhouxf.rpc.transport.netty.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import xyz.zhouxf.rpc.entity.RpcResponse;
import xyz.zhouxf.rpc.factory.SingletonFactory;

/**
 * @author zhouxf
 * @date 2022/10/6
 */
public class NettyClientHandler extends SimpleChannelInboundHandler {

    private final WaitRequests waitRequests;

    NettyClientHandler() {
        this.waitRequests = SingletonFactory.getInstance(WaitRequests.class);
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Object o) throws Exception {
        waitRequests.result((RpcResponse) o);
    }
}
